#include "IniCPP.h"

#include <stdexcept>
#include <exception>

int main( int argc, char ** argv )
{

	try
	{
	
		INI::IniCPP ini( "config.ini" );
		std::cout << "Created the IniCPP instance\n";
		
		
		ini.readIni();
		INI::SECTION & section1 = ini[ "section1" ];
		std::cout << "testing, section1\n";
		for( INI::SECTION::iterator it = section1.begin(); it != section1.end(); ++it )
			std::cout << "\t" << it->first << " = " << ( std::string )it->second << "\n";
			
		INI::SECTION & section2 = ini[ "section2" ];
		std::cout << "testing, section2\n";
		for( INI::SECTION::iterator it = section2.begin(); it != section2.end(); ++it )
			std::cout << "\t" << it->first << " = " << ( std::string )it->second << "\n";
		
		std::cout << "testing, section2, key3: "	<< ( std::string )section2[ "key3" ] << std::endl;
		std::cout << "testing, section2, key4: "	<< ( double )section2[ "key4" ] << std::endl;
		std::cout << "testing, section2, key_8: "	<< ( double )section2[ "key_8" ] << std::endl;
		std::cout << "testing, section2, key2: "	<< ( int )section2[ "key2" ] << std::endl;
		std::cout << "testing, section2, key 5: "	<< ( std::string )section2[ "key 5" ] << std::endl;
		
		std::cout << "modifying section1, key1\n";
		section1[ "key1" ] = INI::IniValue( INI::TYPE_INT );
		section1[ "key1" ].value = new int( 69 );
		
		std::cout << "writing ini file\n";
		ini.writeIni( "config.ini" );
		
		return 0;
		
	}
	catch( std::exception & exc )
	{
	
		std::cerr << exc.what() << "\n";
		
		return 1;
		
	}

}